package com.zjkj.mp.controller.channelManage;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.zjkj.mp.service.channel.ChannelService;
import com.zjkj.mp.utils.Toolkit;
import com.zjkj.mp.vo.channel.MpChannel;

/**
 * 
 * 新建通道控制器
 *
 * @author 陈晨
 * @history
 * <TABLE id="HistoryTable" border="1">
 * 	<TR><TD>时间</TD><TD>描述</TD><TD>作者</TD></TR>
 *	<TR><TD>2013-6-9</TD><TD>创建初始版本</TD><TD>陈晨</TD></TR>
 * </TABLE>
 */
@Controller
public class NewChannelController {

	@Resource(name = "channelServiceImpl")
	private ChannelService channelService;

	/******************************* 新建通道 ***********************************/
	
	/**
	 * 新建通道基本信息
	 * @return
	 */
	@RequestMapping("/newChannel.do")
	public String newChannel() {
		return "channel/newChannel";
	}
	
	/**
	 * 保存通道基本信息
	 * @return
	 */
	@RequestMapping("/insMpChannel.do")
	public String insMpChannel(@ModelAttribute("channel") MpChannel channel, HttpServletRequest req,
			HttpServletResponse res) {
		Toolkit tool = new Toolkit();
		//设置通道时间跟状态
		channel.setTdzt(1);
		channel.setPubtime(tool.getSystemDate());
		int num = channelService.insertMpChannel(channel);
		if(num>0){
			req.setAttribute("info", "录入成功");
		} else {
			req.setAttribute("info", "录入失败");
		}
		return "channel/newChannel";
	}

}
